/**
 * @program: yygh_parent
 * @ClassName OssController
 * @description:
 * @author: zyw
 * @create: 2023-06-03 14:03
 * @Version 1.0
 **/
package com.atguigu.yygh.oss.controller;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.oss.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/admin/oss/file")
@Api(value = "阿里云云存储")
public class OssController {
    @Autowired
    private OssService ossService;

    //文件上传
    @ApiOperation(value = "文件上传")
    @PostMapping("/upload")
    public R upload(MultipartFile file) {
        String url = ossService.upload(file);
        return R.ok().message("文件上传成功").data("url", url);
    }
}
 
